package brwarner.game.ui 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author Brook Jensen
	 */
	public class Bar extends Sprite 
	{
		//Name of measurement
		var _name:String;
		
		//Max width
		var _maxWidth:Number;
		
		//Max amount
		var _maxAmount:Number;
		
		//Current amount
		var _amount:Number;
		
		//Text field object
		var _tf:TextField;
		
		//Bar color
		var _color:uint;
		
		public function Bar( name:String, size:Number, max:Number, color:uint ) 
		{
			_name = name;
			_maxWidth = size;
			_maxAmount = max;
			_amount = 0;
			_color = color;
			_tf = new TextField();
			_tf.text = name;
			_tf.autoSize = "left";
			addChild(_tf);
			redraw();
		}
		
		public function set value( v:Number ) : void
		{
			_amount = v;
			redraw();
		}
		
		private function redraw( )
		{
			graphics.clear();
			graphics.beginFill( _color );
			graphics.drawRect(50, height/2-5, _maxWidth * _amount / _maxAmount, 10 );
			graphics.endFill();
		}
		
	}

}